<?php    
class ControllerCustomerCustomerBlacklist extends Controller { 
	private $error = array();
  
  	public function index() {
		$this->load->language('customer/customer_blacklist');
		$this->document->setTitle($this->language->get('heading_title'));
		$this->load->model('customer/customer_blacklist');
    	$this->getList();
  	}
    
  	private function getList() {
  		$this->data['breadcrumbs'] = array();
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => false
   		);
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('heading_title'),
			'href'      => $this->url->link('customer/customer_blacklist', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
  	
		if (isset($this->request->get['filter_email'])) {
			$filter_email = $this->request->get['filter_email'];
		}else{
			$filter_email = null;
		}
		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}
		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}

		$data = array(
			'filter_email'  => $filter_email,
			'order' => $order,
			'start' => ($page - 1) * $this->config->get('config_admin_limit'),
			'limit' => $this->config->get('config_admin_limit')
		);
		$customer_blacklist_total = $this->model_customer_customer_blacklist->getTotalCustomerBlacklists($data);
		$this->data['customer_blacklists'] = $this->model_customer_customer_blacklist->getCustomerBlacklists($data);
		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_no_results'] = $this->language->get('text_no_results');

		$this->data['column_reason'] = $this->language->get('column_reason');
		$this->data['column_date_added'] = $this->language->get('column_date_added');
		$this->data['column_name'] = $this->language->get('column_name');
		$this->data['column_email'] = $this->language->get('column_email');
		$this->data['column_action'] = $this->language->get('column_action');
		
		$this->data['button_filter'] = $this->language->get('button_filter');

		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}
		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}
		
		$url = '';
  		if (isset($this->request->get['filter_email'])) {
			$url .= '&filter_email=' . $this->request->get['filter_email'];
		}
		if ($order == 'ASC') {
			$url .= '&order=DESC';
		} else {
			$url .= '&order=ASC';
		}
		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}
		$this->data['sort_date_added'] = $this->url->link('customer/customer_blacklist', 'token=' . $this->session->data['token'] . $url, 'SSL');
		
		$url = '';
  		if (isset($this->request->get['filter_email'])) {
			$url .= '&filter_email=' . $this->request->get['filter_email'];
		}
		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}
		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		$pagination = new Pagination();
		$pagination->total = $customer_blacklist_total;
		$pagination->page = $page;
		$pagination->limit = $this->config->get('config_admin_limit');
		$pagination->text = $this->language->get('text_pagination');
		$pagination->url = $this->url->link('customer/customer_blacklist', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
			
		$this->data['pagination'] = $pagination->render();
				
		$this->data['order'] = $order;
		$this->data['token'] = $this->session->data['token'];
		$this->data['filter_email'] = $filter_email;
		
		$this->template = 'customer/customer_blacklist_list.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
				
		$this->response->setOutput($this->render());
  	}
}
?>